package test_junit_shop.ProductStock;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import util.BaseDriver;

import java.util.List;

/**
 * Created by Eric on 2018/2/6.
 * 门店-仓库退货清单
 */
public class WarehouseRefoundList extends BaseDriver{
    private static WarehouseRefoundList wrl = new WarehouseRefoundList();
    public static WarehouseRefoundList getInstance(){
        return wrl;
    }

    public void refound(String customerName) throws InterruptedException {
        Thread.sleep(3000);
        driver.switchTo().defaultContent();
        List<WebElement> frameList = driver.findElements(By.xpath("//iframe[@name='iframeundefined']"));
        driver.switchTo().frame(frameList.get(frameList.size() - 1));

        List<WebElement> refoundList = driver.findElements(By.xpath(String.format("//td[contains(text(), '%s')]/preceding-sibling::td[4]/input", customerName)));
        refoundList.get(0).click();

        driver.findElement(By.xpath("//button[@onclick='edit()']")).click();
        Thread.sleep(1500);

        driver.switchTo().frame(0);
        driver.findElement(By.xpath("//button[@onclick='confirm();']")).click();
        Thread.sleep(2000);

//        driver.switchTo().parentFrame();
        driver.findElement(By.linkText("确定")).click();
        Thread.sleep(1000);
    }
}
